﻿using BasicModuleWebApiJWTAuthorization.DBContextx;
using BasicModuleWebApiJWTAuthorization.Model;
using BasicModuleWebApiJWTAuthorization.Module;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace BasicModuleWebApiJWTAuthorization.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class MemuAuthorizationController : ControllerBase
    {

        public IAuthorizationService _authorizationService { get; set; }

        public MemuAuthorizationController(IAuthorizationService authorizationService)
        {
            this._authorizationService = authorizationService;
        }


        /// <summary>
        /// 菜单(页面)鉴权 页面是否显示菜单页面
        /// </summary>
        /// <param name="t_User"></param>
        /// <returns></returns>
        [HttpGet("MemuAuthorization")]
        public async Task<AuthorizationResult> MemuAuthorization(string MemuAuthorization)
        {
            //菜单(页面)鉴权
            AuthorizationResult authenticateResult = await _authorizationService.AuthorizeAsync(HttpContext.User, HttpContext, MemuAuthorization);
            return authenticateResult;
        }
    }
}
